var t = getApp(), e = t.requirejs("core"), a = (t.requirejs("icons"), t.requirejs("jquery"));
Page({

  data: {
    show:false,
    jiao:0,
    city:[],
    cityIndex:0,//一级下标
    twoTypeIndex:0,//二级下标
    ordinary:[],//主推商品
    recommands_goods:[],//推荐商品
    history_goods:[],//历史商品
    openId:t.getCache("userinfo_openid")
    
  },

  gosearch(){
    wx.navigateTo({
      url: '/pages/goods/index/index?fromsearch=1',
    });
  },

  getCategory: function() {
    var t = this;
    e.get("shop/get_category", {}, function(res) {
        t.setData({
          show:true,
          city: res.category.city,
          ordinary: res.category.ordinary,
          recommands_goods: res.recommands_goods,
          history_goods:res.history_goods,
        });
    });
  },  

  handleChangeCity(e){
    this.setData({
      cityIndex:e.currentTarget.dataset.cityindex,
    })
  },

  handleChangeTwoType(e){
    this.setData({
      twoTypeIndex:e.currentTarget.dataset.twotypeindex,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     // 获取胶囊的位置
    this.setData({
      jiao:wx.getMenuButtonBoundingClientRect()
    })
  },

  onShow:function(){
    this.getCategory();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return e.onShareAppMessage();
  }
})